
package com.test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class SMILMessage implements Serializable
{
    private static final long serialVersionUID = 1L;
    private List<SMILSeries> seriesList;
    private String subject;


    public static SMILMessage create()
    {
        SMILMessage message = new SMILMessage();
        message.setSeriesList(new ArrayList<SMILSeries>());
        return message;
    }


    private SMILMessage()
    {

    }


    /**
     * @return the seriesList
     */
    public List<SMILSeries> getSeriesList()
    {
        return seriesList;
    }


    /**
     * @param seriesList the seriesList to set
     */
    public void setSeriesList(List<SMILSeries> seriesList)
    {
        this.seriesList = seriesList;
    }


    public void addSeries(SMILSeries series)
    {
        seriesList.add(series);
    }


    /**
     * @return the subject
     */
    public String getSubject()
    {
        return subject;
    }


    /**
     * @param subject the subject to set
     */
    public void setSubject(String subject)
    {
        this.subject = subject;
    }


    public String getXml()
    {
        StringBuffer xml = new StringBuffer();
        xml.append("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><smil><body>");

        for (SMILSeries series : seriesList)
        {
            switch (series.getType())
            {
                case SMILSeries.TYPE_SEQUENCE:
                {
                    SequenceSeries sequence = (SequenceSeries) series;
                    xml.append(sequence.getXml());
                    break;
                }
                case SMILSeries.TYPE_PARALLEL:
                {
                    break;
                }

            }
        }

        xml.append("</body></smil>");

        return xml.toString();

    }


    @Override
    public String toString()
    {
        return subject;
    }

}
